package com.jinsi.controller;

import com.jinsi.pojo.InfoData;
import com.jinsi.pojo.Init;
import com.jinsi.pojo.MenuData;
import com.jinsi.service.impl.MenuServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class MenuController {
    @Autowired
    private MenuServiceImpl service;


    //获取左侧导航栏
    @RequestMapping("/getMenu")
    @ResponseBody
    public Init getMenu(){
        InfoData homeInfo = new InfoData();
        homeInfo.setTitle("首页");
        homeInfo.setHref("homepage/homepage.html");
        InfoData logoInfo = new InfoData();
        logoInfo.setTitle("进思财务");
        logoInfo.setImage("images/logo.png");
        logoInfo.setHref("");


        Init init = new Init();
        init.setHomeInfo(homeInfo);
        init.setLogoInfo(logoInfo);

        List<MenuData> oneList = new ArrayList<>();
        List<MenuData> list = service.getParentMeun();

        MenuData menuData = new MenuData();
        menuData.setTitle("欢迎使用财务管理系统");
        menuData.setIcon("fa fa-address-book");
        menuData.setStatus(0);
        menuData.setTarget("_self");
        menuData.setHref("");
        menuData.setChild(list);
        oneList.add(menuData);
        init.setMenuInfo(oneList);
        return init;
    }

    
}
